<?php

/**
 * Created by PhpStorm.
 * User: mj
 * Date: 17-6-7
 * Time: 下午7:48
 */
namespace App\Winged\Auth\Repository ;


use App\Winged\Auth\Api\User;
use App\Winged\Auth\Backend\Api\LogicException;

class UserRepository
{
    protected $defaultPage = 0;

    protected $defaultPageSize = 10 ;


    public function all()
    {
        try{
            $currentPage = (string) request()->input('index', $this->defaultPage);
            $currentPageSize = (string) request()->input('number' ,$this->defaultPageSize);
            $user = User::users([
                'data' => json_encode([
                    'page_index' => $currentPage ,
                    'page_size' => $currentPageSize,
                    'user_id' => '',
                ]),
            ]);
            return $user;
        }catch (LogicException $e){
            return false;
        }
    }

    public function exceptAdmin(){
        $currentPage = request()->input('page', $this->defaultPage);
        $currentPageSize = request()->input('page_size' ,$this->defaultPageSize);
        $user = User::users($currentPage,$currentPageSize);
        return $user;
    }
}
